var mysql=require("mysql");
var i=0;
var connection = mysql.createConnection({
    host: 'rm-uf6bu9e642pam0d2ro.mysql.rds.aliyuncs.com',
    user: 'root',
    password: 'Chzh5188',
    database: 'spider'
});
connection.connect();
exports.init= function(){
    connection.query("delete from flightinfo",function(err,res){
        if(err) throw err;
        console.log("表初始化成功");
        contexts[contexts.length]={text:"数据表初始化完成"};
    });
}
exports.sql = function(sql,callback){
    // console.log(sql);
    connection.query(sql,function(err,res){
        if(err) throw err;
        i++;
        console.log("第"+i+"条语句执行成功");
        contexts[contexts.length]={text:"第"+i+"条语句执行完成"};
        // console.log("Datahandle.js"+contexts);
        if(callback) callback(res);
        // connection.end();
    });
}